﻿<?php


	if(!$_POST['text'])
	{	
		header("Content-Type: application/octet-stream");
		header("Accept-Ranges: bytes");
		Header("Accept-Length: ".filesize('temp/webpage.html'));
		header("Content-Disposition: attachment; filename=temp/webpage.html");	
		echo file_get_contents('temp/webpage.html');
	

	}else{



	
		$file = fopen('temp/webpage.html','w');
		$file_contents = '<html>'.
		'<head>'.
		''."\r\n".
		''."\r\n".
		'<link href="http://www.francescomalagrino.com/BootstrapPageGenerator/3/css/bootstrap-combined.min.css" rel="stylesheet" media="screen">'."\r\n".
		''."\r\n".
		'</head>'."\r\n".
		'<body>'."\r\n";
		$file_contents .= $_POST['text'];
		$file_contents .='</body>'."\r\n".
				'</html>'; 
		fwrite($file,$file_contents);
		fclose($file);
		header("location:create_file.php");
	}
?>